{assign var=form value=$form->toArray()}

{form action=`$form._action` name=`$form._formname` method=`$form._method` enctype="multipart/form-data"}
<br/>
	<table width="100%" border='0'>
	{foreach from=$form._fields item=field key=cid}
		<tr>
			<td valign='top' style='width:130px;text-align:right;font-weight:bold;padding:2px;'>{$field.label}{if $field.label}:{/if}</td>
			<td style='text-align:left;padding:2px'>{call_input_plugin type=$field.type name=$field.name add_params=$field} {assign var=fname value=$field.name} {if $messages.$fname}<div class='error' for='{$fname}_id'>{foreach from=$messages.$fname.message item=err}{$err}<br/>{/foreach}</div><br/>{/if}</td>
		</tr>
	{/foreach}
	</table>
<br/>
{/form}


<script type='text/javascript'>

$(document).ready(function() {ldelim} 
    $('#{$form._formname}').ajaxForm({ldelim} 
    	beforeSubmit: function(){ldelim}return $('#{$form._formname}').valid(){rdelim},
        dataType:  'json', 
        success:   processJsonFor{$form._formname} 
    {rdelim}); 
{rdelim});



function processJsonFor{$form._formname}(data) {ldelim}
    formToReplace = $('#{$form._formname}').parent().html(data.content);
    pasteMessages(data.messages);
{rdelim}
</script>

